﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="../MasterPages/MedianamikModule.Master" CodeBehind="blogList.aspx.cs" Inherits="Medianamik.UI.Blog.blogList" %>

<asp:Content ID="ContextMenuContent" ContentPlaceHolderID="ContextMenu" runat="server">
	<asp:UpdatePanel ID="addNodeUpdatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
	        <asp:HyperLink ID="lnkAddNode" runat="server" Target="TypeSelectorWindow" class="Action BtAjouter"
                onclick="GetRadWindowManager().Open(null, 'TypeSelectorWindow');" Text="<%$ Resources: Medianamik_ContentManagement, NewNodeButtonText %>" />
	        <asp:HyperLink runat="server" ID="ReturnLink" CssClass="Action BtAnnuler-Inactif" Text="<%$ Resources: Medianamik_Global,Cancel %>" />
	        
	    </ContentTemplate>
	</asp:UpdatePanel>
</asp:Content>

<asp:Content ID="CenterContent" ContentPlaceHolderID="CenterContent" runat="server">
    <asp:UpdatePanel ID="breadcrumbUpdatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
             <med:BreadcrumbTrail ID="bctFilAriane" runat="server" CssClass="FilAriane" />
        </ContentTemplate>
    </asp:UpdatePanel>
    
    <asp:UpdatePanel ID="mainUpdatePanel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <telerik:RadGrid runat="server" OnItemDataBound="Grid_ItemDataBound" ID="blogContainersGrid" EnableEmbeddedSkins="false" Skin="Medianamik" AllowPaging="false" AutoGenerateColumns="false" Width="100%" OnItemCommand="Grid_ItemCommand">
                <MasterTableView DataKeyNames="ID">
                    
                </MasterTableView>
            </telerik:RadGrid>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

<asp:Content ID="ExternalContent" ContentPlaceHolderID="ExternalContentHolder" runat="server">
    <telerik:RadScriptBlock runat="server" ID="scriptBlock">
        <script type="text/javascript">
            //<![CDATA[

            <asp:Repeater id="rptNodeTypeUrls" runat="server">
                <HeaderTemplate> var urls = new Array( </HeaderTemplate>
                <ItemTemplate>new NodeTypeUrl("<%# Eval("key") %>","<%# Eval("value") %>")</ItemTemplate>
                <SeparatorTemplate>, </SeparatorTemplate>
                <FooterTemplate>); </FooterTemplate>                
            </asp:Repeater>            
            
            function NodeTypeUrl(pKey, pUrl)
            {
                this.key = pKey.toString().toLowerCase();
                this.url = pUrl;
            }

            function onNodeTypeSelected(radWindow, returnValue) {
                if (returnValue) {
                var argument = returnValue.get_argument();
                if (argument && argument.NodeTypeId) {                    
                    var redirectUrl;
                    if (argument.ParentNodeId)
                        redirectUrl = GetUrlFromNodeType(argument.NodeTypeId) + "?parentid=" + argument.ParentNodeId + "&typeid=" + argument.NodeTypeId;                    
                    else
                        redirectUrl = GetUrlFromNodeType(argument.NodeTypeId);

                    location.href = redirectUrl
                }
                }
            }

            function GetUrlFromNodeType(nodeType) {
                nodeType = nodeType.toString().toLowerCase();
                for (var i = 0; i < urls.length; i++)
                    if (urls[i].key == nodeType) 
                        return "/medianamik/Blog/" + urls[i].url;
                        
                return "/medianamik/Blog/editCustomType.aspx";
            }
            //]]>
        </script>
    </telerik:RadScriptBlock>
</asp:Content>
